from pymongo import MongoClient
import statistics
client = MongoClient(port=27017)
db=client['tiktok']
collist=['sfxmakeup','WeekendVibes']
#for col in db.list_collection_names():
for col in collist:
    print(col)
    for obj in db[col].find():
        if len(obj['video_feature']['audio']['yamnet'])>0 and 'var_yamnet' not in obj['video_feature']['editing'].keys():
            yv=statistics.variance(obj['video_feature']['audio']['yamnet'])
            db[col].update_one({'_id':obj['_id']},{'$set':{'video_feature.editing.var_yamnet':yv}})